import org.junit.Test;

import java.io.InputStream;
import java.util.Iterator;
import java.util.stream.Stream;

public class StreamDay01 {
    @Test
    public void StreamTest(){
        Stream<String> s = Stream.of("1", "2","3","4");
        s.forEach(System.out::println);
        System.out.println(s);

        Stream.iterate(0,x->x+3).limit(4).forEach(System.out::println);

    }
    /**
     * &是AND运算符，是一种位运算符。有0为0，全1为1
     * 运算规则如下：
     * 1&1=1;
     * 1&0=0;
     * 0&1=0;
     * 0&0=0;
     */
    @Test
    public void test01() {
        //a的二进制补码表示为：0000 0000 0000 0000 0000 0000 0000 0111
        int a = 7;
        print2Binary(a);
        //b的二进制补码表示为：0000 0000 0000 0000 0000 0000 0000 0010
        int b = 2;
        print2Binary(b);
        //c=a&b的二进制补码表示为：0000 0000 0000 0000 0000 0000 0000 0010
        int c = a & b;//十进制为2
        System.out.println("a&b=" + c);
        print2Binary(c);
    }

    private void print2Binary(int c) {
    }
    @Test
    public void test02(){
        int a =1;
        int b = 2;
        System.out.println(a^b);
        String s ="你好";
        String s1= "你好";
        System.out.println(s==s1+"----------------"+s.equals(s1));
        System.out.println(s.equals(s1));
        int c = -20;
        System.out.println(~c);
        int h =7;
        System.out.println(~h);
        System.out.println(~-5);
    }



}
